import axios from 'axios';
import { ElMessage } from "element-plus";
const instance:any = axios.create({
    baseURL: process.env.VUE_APP_BASE_URL,
    timeout: 5000,
    method: 'GET'
});

instance.interceptors.request.use(
    (config:any) => {

        return config
    },
    (error:any)=> {
        ElMessage.error(error.message)
        return Promise.reject(error);
});

// 添加响应拦截器
instance.interceptors.response.use(
    (response:any)=>{
        return response
    },
    (error:any)=>{
        ElMessage.error(error.message)
        return Promise.reject(error);
    }
)

export { instance }
